import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: resolve => require(['@/views/login.vue'], resolve)
  },
  {
    path: '/deskTop',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
	children:[
		{
		    path: 'home',
		    component: resolve => require(['@/views/deskTop/home.vue'], resolve),
			meta:{
				keepAlive:false,
			}
		}
	]
  },
  //首页配置
  {
    path: '/homeSet',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'homeShow',
  		    component: resolve => require(['@/views/homeSet/homeShow.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'内容展示'
			}
  		},
		{
		    path: 'groupCode',
		    component: resolve => require(['@/views/homeSet/groupCode.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'群二维码'
			}
		},
		{
		    path: 'popUp',
		    component: resolve => require(['@/views/homeSet/popUp.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'弹窗公告'
			}
		},
		{
		    path: 'topCarousel',
		    component: resolve => require(['@/views/homeSet/topCarousel.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'顶部轮播'
			}
		},
		{
			path: 'address',
			component: resolve => require(['@/views/homeSet/address.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'通讯地址'
			}
		},
		{
			path: 'payment',
			component: resolve => require(['@/views/homeSet/payment.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'结算方式'
			}
		},
		{
			path: 'homeNotice',
			component: resolve => require(['@/views/homeSet/homeNotice.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'首页公告'
			}
		},
		{
			path: 'myPage',
			component: resolve => require(['@/views/homeSet/myPage.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'我的页面'
			}
		},
		{
			path: 'watermark',
			component: resolve => require(['@/views/homeSet/watermark.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'水印'
			}
		},
		{
			path: 'know',
			component: resolve => require(['@/views/homeSet/know.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'常用问题'
			}
		},
		{
			path: 'bookaddress',
			component: resolve => require(['@/views/homeSet/bookaddress.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'踏浪通讯录'
			}
		},
		{
			path: 'attention',
			component: resolve => require(['@/views/homeSet/attention.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'关注我们'
			}
		},
		{
			path: 'find',
			component: resolve => require(['@/views/homeSet/find.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'探索'
			}
		},
  	]
  },
  //最新消息
  {
    path: '/newMessage',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'cate',
  		    component: resolve => require(['@/views/newMessage/cate.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'消息分类'
  			}
  		},
  		{
  		    path: 'newMessage',
  		    component: resolve => require(['@/views/newMessage/newMessage.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'最新消息'
  			}
  		},
  		{
  		    path: 'model',
  		    component: resolve => require(['@/views/prodectSys/model.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'型号'
  			}
  		}
  	]
  },
  //产品库
  {
    path: '/prodectSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'brand',
  		    component: resolve => require(['@/views/prodectSys/brand.vue'], resolve),
  			meta:{
  				keepAlive:false,
				title:'品牌'
  			}
  		},
		{
		    path: 'serial',
		    component: resolve => require(['@/views/prodectSys/serial.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'系列'
			}
		},
		{
		    path: 'model',
		    component: resolve => require(['@/views/prodectSys/model.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'型号'
			}
		}
  	]
  },
  //报价表
  {
    path: '/offers',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'tableList',
  		    component: resolve => require(['@/views/offers/tableList.vue'], resolve),
  			meta:{
  				keepAlive:false,
				title:'报价表'
  			}
  		}
  	]
  },
  //图片管理
  {
    path: '/imgSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'imgList',
  		    component: resolve => require(['@/views/imgSys/imgList.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'图片管理'
  			}
  		}
  	]
  },
  //用户管理
  {
    path: '/userSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'userList',
  		    component: resolve => require(['@/views/userSys/userList.vue'], resolve),
  			meta:{
  				keepAlive:false,
  				title:'用户列表'
  			}
  		},
		{
		    path: 'bdList',
		    component: resolve => require(['@/views/userSys/bdList.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'报单列表'
			}
		},
		{
		    path: 'applicationList',
		    component: resolve => require(['@/views/userSys/applicationList.vue'], resolve),
			meta:{
				keepAlive:false,
				title:'用户申请'
			}
		}
  	]
  },
  //活动管理
  {
    path: '/activeSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
		{
		    path: 'withdrawalPrice',
		    component: resolve => require(['@/views/activeSys/withdrawalPrice.vue'], resolve),
			meta:{
				keepAlive:false,
			}
		},
  		{
  		    path: 'setRewardRole',
  		    component: resolve => require(['@/views/activeSys/setRewardRole.vue'], resolve),
  			meta:{
  				keepAlive:false,
  			}
  		},
		{
		    path: 'kind',
		    component: resolve => require(['@/views/activeSys/kind.vue'], resolve),
			meta:{
				keepAlive:false,
			}
		},
		{
		    path: 'bindUserList',
		    component: resolve => require(['@/views/activeSys/bindUserList.vue'], resolve),
			meta:{
				keepAlive:false,
			}
		},
		{
		    path: 'withHistoryList',
		    component: resolve => require(['@/views/activeSys/withHistoryList.vue'], resolve),
			meta:{
				keepAlive:false,
			}
		},
  	]
  },
]

// 解决报错
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};
// replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};




const router = new VueRouter({
  mode: 'hash',
  routes
})



export default router
